Beebhack
__TOC__ Purpose This site describes how to re-purpose BBC online content. To utilise material already paid for by the licence payers in a manner that suits the end user. Origin / History This wiki was started as an attempt to bring together the information that was being discovered about the many great BBC services, particularly the iPlayer and particularly after the iPhone beta service was launched. There are many very useful discussions occurring about the iPhone version of iPlayer and as a result, a great deal of replication of effort. This is an attempt to reduce this replication and organise that information. Services Live radio Podcasts The BBC podcasts are generally edited highlights of select radio programmes. These are all documented on http://www.bbc.co.uk/radio/podcasts/directory/ Each podcast is encoded at 44KHz 64kbps MP3 and has an RSS 2.0 feed associated with it. MP3s are available online on the BBC website for a period of 7 days from date published. Some Podcast series are not governed by this 7 day rule, but there aren't many. Also, some of the Podcasts are restricted to the UK only. There is a Podcasting feed created that lists all current Podcasts available for download as well. URL: http://downloads.bbc.co.uk/podcasts/ppg.xml Schema: http://downloads.bbc.co.uk/podcasts/ppg.xsd The feed is updated every 30 minutes and is a simplified data dump of the internal Podcast database (well, a very stripped down version). It is used internally to create feeds, one of them being the feed that powers the BBC Podcasts directory. The feed also includes data on those which are UK only. It should be noted that Podcasts that include the "" tag/info should really be ignored as those are just random data Podcasts. They're used internally for testing, hence the network id being "test". Other variables to look out for are active and public attribute in the programme tag. Active here just tells you if the Podcast series is actually still running at this current point in time. Because not all programmes run through out the year (e.g. The Chequered Flag which is about F1 racing) then the active flag is set to false when the programme series ends. The public attribute is really there for excluding things from Podcast directory or Podcasts that are currently being worked on but not ready yet. Again, some of these would be experimental and so might be full of random data that would not make sense. Think of it as "nothing to see here, please move along" flag but feel free to take a look at it anyway as it is on a public facing server :) News / weather data iPlayer Radio (was 'Listen Again') While replaying most programmes, there is a 'listen using stand-alone real player' link. This is a link to a .ram file, eg. http://www.bbc.co.uk/radio/aod/shows/rpms/radio4/anyanswers.ram . This file merely contains the address of the stream, served using rtsp, eg. rtsp://rmv8.bbc.net.uk/radio4/sat1402.ra (this link sometimes contains start and end times for the program). The website http://dave.org.uk/streams/ allow you to browse all the programs on listen again, and get a direct link to the stream. Similar is http://www.comfyyoghurt.co.uk/bbc_streams/ provides easy browsing for mobile browsers. Once you have the link to the stream, you can save it, using the mplayer -dumpstream . This will play back the stream in real time, saving the file. Programs such as Net Transport and streambox vcr allow you to save rtsp streams faster, by opening multiple connections simultaneously. Avoid flashget. I know of no such programs for linux, suggest being patient with mplayer. ListenLater is an extension for Firefox that saves iPlayer Radio audio streams as MP3. Many non music programs on the radio 4 and world service offer podcasts (see above) - download mp3, so check for this first. iPlayer TV General technical overview Programme IDs All programme episodes on BBC TV are assigned a programme ID (PID) made up of lower-case letter and numbers of around 8 characters. More information on the format of the PID's can be found at the BBC Programme Guide. For Instance for Torchwood, you can see which programmes are available on iPlayer. In addition to this, it is possible for episodes in iPlayer to have several published "versions". Every episode of a programme should have at least one version - the "original". Other versions that exist are: Retrieving programme meta-data Detailed metadata can be retrieved from XML resources available for each episode with URLs of the form http://www.bbc.co.uk/iplayer/metafiles/episode/.xml This contains information on the episode versions available and descriptive information on episodes including still image URLs. This information appears to also specify some of the "More Like This" programs. 3rd Party iPlayer Scripts / Programs * iPlayer RSS feed creator *Enhanced iPlayer Guide See also List of known interoperable scripts / programs Windows P2P version controversy Articles on DRM schemes * Quick guide: Cracked DRM systems Flash / RTMP stream version The web-based Adobe Flash version of the iPlayer was introduced on the 13th of December 2007, designed to bring the iPlayer to a larger audience than the Windows XP only iPlayer. http://www.theregister.co.uk/2007/12/13/flash_iplayer_launch/ The service streams the video over Abobe's proprietary RTMP, although the video itself is DRM-free. Video URL resolving process The flash client goes through the following process to resolve the location of each episode ID video: # The media selector URL for the relevant episode is requested from http://www.bbc.co.uk/mediaselector/3/stream/check/iplayer?pid=[PID] this gives the script: ## token ## server ## identifier # These make up an authentication string auth of the form auth=token&aifp=v001&slist=identifier # The server string is used to fetch ident data from http://[server]/fcs/ident which contains the IP address of the media server # The final stream URL is then resolved as rtmp://ip_address:1935/ondemand?_fcs_vhost=server&auth An example of this algorithm can be found in this PHP script: http://www.strawp.net/files/download/iplayer_url.zip At time of writing only Adobe products such as Flash support RTMP, although it is currently on the libcurl TODO list. iPhone / H.264 over HTTP version On the 7th of March 2008 the BBC launched an iPhone compatible version of their web-based iPlayer service. Visitors to iPlayer site using an iPhone would be presented with a slightly tweaked interface, but crucially where users of the site using a desktop web browser, iPhone users would see an embedded Quicktime player streaming H.264 video (referred to on iPlayer as MP4) over a normal HTTP protocol. User-Agent checking It was quickly spotted by web developers everywhere that all the site was doing to identify iPhone users was inspect the "User-Agent" string sent by the client. By altering this string using freely available browser plugins, anyone could access this feed and view the "MP4" location, opening it any application they wished. This "bug" was widely recognised as first published by user "Irregular Shed" on Flickr: http://www.flickr.com/photos/twindx/2316284105/ Following this observation, countless developers created their own scripts to pull down iPlayer content. charter controversy BBC response to non-iPhone clients using the service On the 13th of March 2008 the BBC released a "fix" designed to stop non iPhone users downloading the H.264 video files: * http://news.bbc.co.uk/1/hi/technology/7293988.stm * http://www.theregister.co.uk/2008/03/13/iplayer_iphone_drm_loophole_closed/ Although the BBC did not announce the nature of their "fix", it was quickly uncovered by monitoring network traffic between Apple devices and the iPlayer servers. Whereas before the service had only checked for the iPhone/iPod browser's User-Agent HTTP header, it was now also checking the distinctive User-Agent and Range headers sent by the media subsystem. Once this was added to existing scripts, they continued to function largely as normal. By the end of that day, a few developers had already updated their scripts to work around the update: * http://www.flickr.com/photos/twindx/2316284105/#comment72157604109685610 * http://po-ru.com/diary/bbc-iplayer-fix-hacked-again/ = Update to video file encoding as of 6th June 2008 = From early June 2008, the BBC changed the mechanism used to encode their videos for the iPhone/iPod Touch. Although downloading via spoofing still works, the downloaded files will not play on any common desktop software. It is possible that a DRM scheme has been applied to the previously unencrypted H.264 video. A look at the video file headers suggests that the audio is now encoded by libfaac (1.26.1 unstable). Although no DRM scheme has been formally identified, the most likely candidate is Fairplay, which is built into QuickTime and the iPhone. = Update to video file encoding as of 8th June 2008 = In fact the DRM appears to be a simple XOR of the plain vanilla MP4 with a repeating two-byte pattern. Savvy people will be able to compare an encrypted programme with their existing plaintext MP4 from before the recent update in order to reveal the details. Overview of video request process The process for requesting the H.264 video is as follows: # Video page is requested and a "BBC-UID" cookie is set, containing the URL-encoded User-Agent string of the browser. # The iPhone version of iPlayer renders a Quicktime object into the page which requests the video URL as http://www.bbc.co.uk/mediaselector/3/auth/iplayer_streaming_http_mp4/[PID]?[RAND] where PID is the programme version ID and RAND is a random number, although the random number is apparently unused by the service. This URL must have: ## The Quicktime User-Agent header ## The BBC-UID cookie ## A "Range" header of "0-1" # The video URL then 302 redirects to a much more complex URL. The same headers are sent ## BBC-UID cookie ## Quicktime User-Agent ## The "Range" header, this time using "0-" Example HTTP headers sent by an iPhone session This is then followed by a redirect response and the client creates another request to the actual media location: A Very Quick "one-liner" download script The following script is technically one line of shell script. It requires curl, cut, grep and sed: If it's saved off to a script file, pass it an web iPlayer episode page and it will save the episode to a file named "iplayer_download.mov". BBC tightening of User Agent check On 7th April 2008 it was noticed by "Irregular Shed" that the BBC have tightened up the user agent checking required to convince iPlayer that it is talking to an iPhone/iPod Touch. Whereas previously it was sufficient to pass nothing more than "iPhone" as a user agent string to access the service, it now checks for more. To be on the safe side, all scripts should make use of the full, verbose user agent string: ... or the iPod Touch equivalent: In addition, there may now be multiple pid values in the HTML, yielding different versions of the video with different availability periods: a script must choose the right one in order to download successfully. Note that it is recommended to use the episode metadata XML as opposed to screen scraping the player page as an update in page code may break a script based on screen scraping, whereas official BBC clients rely on the metadata XML. See section on Programme IDs. List of known interoperable scripts / programs * Ruby: http://po-ru.com/files/iplayer-dl (Subversion repository at http://paulbattley.googlecode.com/svn/iplayer-dl/) * PHP: http://www.strawp.net/files/download/iplayer_dl.zip * PHP: http://hublog.hubmed.org/archives/001634.html * Python (XBMC plugin): http://code.google.com/p/xbmc-iplayer/ * Perl: http://www.strawp.net/files/download/iplayer_perl.zip * Lua: http://pastey.net/85893 * Mac OS X Cocoa-based downloader: http://macupdate.com/info.php/id/27354/iplayer-downloader * Mac OS X Applescript-based GUI: http://labsix.net/beeb * Windows GUI: http://po-ru.com/diary/iplayer-downloads-for-the-masses/ iPlayer for Nintendo Wii On 9th April 2008, the BBC announced that a beta version of iPlayer for the Nintendo Wii was in late stages on development, with a beta version available immediately and a more polished version later in the year. It will appear within the Internet channel of the Wii's UI. The Wii version is more of a tweak to the existing web version than the iPhone specific version is as the Wii Internet Channel is simply a version of the Opera Browser (version 9.00 upwards) The changes are as follows: * The server detects the browser User-Agent and adds a javascript flag "_WII = true" to the inline javascript on the programme view page * The javascript file iplayer_info.js uses this flag in a few places to determine the lifetime of the streamed media, but mostly just to fall back to a flash 7 compatible stream * The iPlayer client is loaded as normal with these variables. The stream appears to use the RTMP protocol as with the normal browser client, as opposed to an HTTP connection which the iPhone uses and is in the lower quality Sorenson Spark codec as opposed to the ON2 VP6 codec used in later Flash versions. More technical information is on Anthony Rose's blog. The User-Agent used by the Production Nintendo Wii is: Opera/9.10 (Nintendo Wii; U; ; 1621; en) Alternative Wii Interface An unofficial alternative interface for browsing iPlayer on the Wii, named WiiPlayer, was released on May 28th. The interface is designed to overcome the usability problems that arise when using the standard iPlayer webpage on the small fixed width resolution of Wii Opera. WiiPlayer is optimised for standard definition TVs and styled for better integration with the existing Wii UI. To use this interface point your Wii browser at: http://defaced.co.uk/wiiplayer/